<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class GroupAdd extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        $this->userId = auth('api')->user()->id;
        return $this->userId;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            // unique:albums,name,'.$this->userId.'user_id
//            'user_id' => 'required|numeric|unique:groups|max:255',
            'name' => 'required|string|min:1|max:15|unique:groups,name',
            'background' => 'required|string',
            'intro' => 'required|string',
        ];
    }

    /**
     * 获取已定义的验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'name.required' => '圈子名称不能为空',
            'name.unique' => '圈子名称已存在',
            'name.min' => '圈子名称长度不能少于1个字',
            'name.max' => '圈子名称长度不能多于15个字',
            'background.unique' => '背景图片不能为空',
            'intro.required'  => '简介不能为空',
        ];
    }


}
